<!--设置模块唯一ID-->
<div>
<!--列表-->
<section class="content">

</section>
<!--添加、修改弹出层-->
<script type="text/template" data-for="tp_editor">
    <form role="form" class="form-horizontal">
        <div class="box-body box-profile">
            <img class="profile-user-img img-responsive img-circle" src="./dist/img/user4-128x128.jpg" alt="User profile picture">
            <input type="file" data-upload="avatar" style="display: none"/>
            <h3 class="profile-username text-center">张三12</h3>
            <p class="text-muted text-center">技术部-前端开发工程师</p>
        </div>

        <div class="u-box">
            <div class="u-box-header">
                <h3>账号信息</h3>
            </div>
            <div class="u-area">
                <div class="form-group">
                    <label class="col-sm-2 control-label">登录名</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p1"
                               value="<%=data.p1?data.p1:''%>">
                        <input type="hidden" class="form-control" name="id"
                               value="<%=data.id?data.id:''%>">
                    </div>
                    <label class="col-sm-2 control-label">密码</label>
                    <div class="col-sm-4">
                        <input type="password" class="form-control" name="password"
                               value="<%=data.p2?data.p2:''%>">
                    </div>
                </div>
                <div class="form-group">
                    <button type="button" class="btn btn-danger pull-right button-rig" id="modifyWord">修改密码</button>
                </div>
            </div>
        </div>

        <div class="u-box">
            <div class="u-box-header">
                <h3>个人信息</h3>
            </div>
            <div class="u-area">
                <div class="form-group">
                    <label class="col-sm-2 control-label">性别</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p3"
                               value="<%=data.p3?data.p3:''%>">
                    </div>

                    <label class="col-sm-2 control-label">年龄</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p4"
                               value="<%=data.p4?data.p4:''%>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">出生日期</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p5"
                               value="<%=data.p5?data.p5:''%>">
                    </div>

                    <label class="col-sm-2 control-label">入职日期</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p6"
                               value="<%=data.p6?data.p6:''%>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">政治面貌</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p7"
                               value="<%=data.p7?data.p7:''%>">
                    </div>

                    <label class="col-sm-2 control-label">户口性质</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p8"
                               value="<%=data.p8?data.p8:''%>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">所在城市</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p9"
                               value="<%=data.p9?data.p9:''%>">
                    </div>

                    <label class="col-sm-2 control-label">现住址</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p10"
                               value="<%=data.p10?data.p10:''%>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">联系电话</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p11"
                               value="<%=data.p11?data.p11:''%>">
                    </div>

                    <label class="col-sm-2 control-label">身份证号</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p12"
                               value="<%=data.p12?data.p12:''%>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">身份证地址</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p13"
                               value="<%=data.p13?data.p13:''%>">
                    </div>

                </div>
            </div>
        </div>


        <div class="u-box">
            <div class="u-box-header">
                <h3>合同信息</h3>
            </div>
            <div class="u-area">
                <div class="form-group">
                    <label class="col-sm-2 control-label">合同类别</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p14"
                               value="<%=data.p14?data.p14:''%>">
                    </div>

                    <label class="col-sm-2 control-label">人员类别</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p15"
                               value="<%=data.p15?data.p15:''%>">
                    </div>
                </div>
            </div>
        </div>

        <div class="u-box">
            <div class="u-box-header">
                <h3>婚姻以及家庭信息</h3>
            </div>
            <div class="u-area">
                <div class="form-group">
                    <label class="col-sm-2 control-label">婚姻状况</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p16"
                               value="<%=data.p16?data.p16:''%>">
                    </div>

                    <label class="col-sm-2 control-label">子女状况</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p17"
                               value="<%=data.p17?data.p17:''%>">
                    </div>
                </div>
            </div>
        </div>

        <div class="u-box">
            <div class="u-box-header">
                <h3>紧急联系人</h3>
            </div>
            <div class="u-area">
                <div class="form-group">
                    <label class="col-sm-2 control-label">紧急联络人</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p18"
                               value="<%=data.p18?data.p18:''%>">
                    </div>

                    <label class="col-sm-2 control-label">与本人关系</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p19"
                               value="<%=data.p19?data.p19:''%>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">电话</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p20"
                               value="<%=data.p20?data.p20:''%>">
                    </div>
                </div>
            </div>
        </div>

        <div class="u-box">
            <div class="u-box-header">
                <h3>教育背景</h3>
            </div>
            <div class="u-area">
                <div class="form-group">
                    <label class="col-sm-2 control-label">毕业院校</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p21"
                               value="<%=data.p21?data.p21:''%>">
                    </div>

                    <label class="col-sm-2 control-label">所学专业</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p22"
                               value="<%=data.p22?data.p22:''%>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">学历</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p23"
                               value="<%=data.p23?data.p23:''%>">
                    </div>

                </div>
            </div>
        </div>
        <!--<div class="box-footer">-->
            <!--<button type="submit" class="btn btn-primary pull-right">提交</button>-->
        <!--</div>-->
    </form>
</script>

<script>
    USEN(function (param) {
        //模块ID(全系统唯一)
        var id = "#"+this.id;
        var that = this;

        //定义页面变量
        var $el = $(id);
        var $editor = $el.children('script[data-for=tp_editor]');
        var verification = /[0-9a-zA-Z_]{6,16}/;
        $.ajax({
            url:"./simdata/common_modify_action.json",
            success:function(data){
                $el.children(".content").html(function(){
                    return _.template($editor.html())({
                        data:data
                    })
                });

                //提交表单
                $el.find("form").ajaxForm({
                    url: './simdata/common_add_action.json',
                    beforeSubmit: function (data) {
                        var newWord = $('#newPassWord').val();
                        if(verification.test(newWord) && $('#newPassWord').val()==$('#confirmNewPassWord').val()){
                            $el.find('.word-hidden').remove();
                            $('#modifyWord').show();
                        }else if(!$('#newPassWord').val()){
                            USEN.notifyAlert({
                                type:"error",
                                title: "错误",
                                content: '请输入新密码'
                            });
                            return false;
                        }else if(!$('#confirmNewPassWord').val()){
                            USEN.notifyAlert({
                                type:"error",
                                title: "错误",
                                content: '请确认新密码'
                            });
                            return false;
                        }else if(!verification.test(newWord)){
                            USEN.notifyAlert({
                                type:"error",
                                title: "错误",
                                content: '密码只能是英文数字与下划线且长度在4-16之间'
                            });
                            return false;
                        }else if($('#newPassWord').val()!=$('#confirmNewPassWord').val()){
                            USEN.notifyAlert({
                                type:"error",
                                title: "错误",
                                content: '新密码与确认新密码不一致'
                            });
                            return false;
                        }
                    },
                    success: function (data, state, obj) {
                        USEN.notifyAlert({
                            title: "提示:",
                            content: '操作成功'
                        });
                    }
                });
                $el.find('#modifyWord').on('click',function () {
                    $(this).hide();
                    $(this).parent().append("<label class='col-sm-2 control-label word-hidden'>原密码</label>"+
                    "<div class='col-sm-4 word-hidden'>"+
                    "<input type='password' class='form-control' name='oldPassWord' id='oldPassWord'>"+
                    " </div>"+
                    "<label class='col-sm-2 control-label word-hidden'>新密码</label>"+
                    "<div class='col-sm-4 word-hidden'>"+
                    "<input type='password' class='form-control' name='newPassWord' id='newPassWord'>"+
                    "</div>");
                    $(this).parent().parent().append("<div class='form-group word-hidden'>"+
                    "<label class='col-sm-2 control-label'>确认新密码</label>"+
                    "<div class='col-sm-4'>"+
                    "<input type='password' class='form-control' name='confirmNewPassWord' id='confirmNewPassWord'>"+
                    "</div>"+
                    "<button type='submit' class='btn btn-danger pull-right button-rig' id='confirmWord'>确认修改</button>"+
                    "</div>");
                });

                $el.find('[name]').attr("disabled","disabled");

            }
        })

    });
</script>
</div>